<?php
include "konek.php";
include "deletefile.php";
$delete= new delete;
if(isset($_GET['posting']))
{

	if (!isset($_GET['id']))
	{
		?><script language="javascript">alert('DATA TIDAK ADA');
		document.location='../tableposting.php'</script><?php
	}
	else
	{
	$id=$_GET['id'];
	$sql=mysql_query("DELETE FROM posting WHERE idpost='$id' ");
	?><script language="javascript">alert('DATA TELAH DIHAPUS');
		document.location='../tableposting.php'</script><?php
	}
}
elseif (isset($_GET['user'])) 
{
	$user=$_GET['user'];
	if (!isset($_GET['id']))
	{
		?><script language="javascript">alert('DATA TIDAK ADA');
		document.location='../tableuser.php'</script><?php
	}
	else
	{
	$id=$_GET['id'];
	if($user=='siswa')
	{
		$username=mysql_query("SELECT * from siswa where id_siswa='$id'");
		$usr=mysql_fetch_assoc($username);
		$dir=$usr['username'];
		$delete->deleteDir('../../uploads/source/siswa/$dir');
		$sql=mysql_query("DELETE FROM siswa WHERE id_siswa='$id' ");
	?><script language="javascript">alert('DATA TELAH DIHAPUS');
		document.location='../tableuser.php'</script><?php
	}
	else {
	$directory=$_GET['directory'];
		$delete->deleteDir('../../uploads/source/guru/'.$directory.'/');
		
		$sql=mysql_query("DELETE FROM guru WHERE id_guru='$id' ");
	?><script language="javascript">alert('DATA TELAH DIHAPUS');
		document.location='../tableuser.php'</script><?php
	}
	
	}	
}
?>